<%@page contentType="text/html;charset=utf-8"%>
<%@include file="../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>用户注册 - 当当网</title>
		<link href="${pageContext.request.contextPath}/css/login.css"
			rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/page_bottom.css"
			rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/prototype-1.6.0.3.js">
		</script>
		<script type="text/javascript">
			function validateForm(form){
				var isSubmitForm=checkEmailAjax(form.email.value)&
															 checkPassword(form.password1.value);
				return isSubmitForm==0?false:true;
			}
			function checkEmailAjax(email){
				//var url="checkEmail.do?email="+document.getElementById('txtEmail').value;
				//var url="checkEmail.do?email="+$('ctl00')['txtEmail'].value;
				//var url="checkEmail.do?email="+$('ctl00').email.value;
				//var url="checkEmail.do?email="+$('ctl00')['email'].value;
				//var url="checkEmail.do?email="+$('ctl00').txtEmail.value;
				var url="checkEmail.do?email="+email;
				var flag=false;
				new Ajax.Request(url,{
					method:'get',
					asynchronous:false,
					onSuccess:function(xmlHttpRequest){
						var jsonString=xmlHttpRequest.responseText;
						var obj=jsonString.evalJSON();
						flag=obj.value;
						//alert(flag);
					}
				});
				if(!flag){
					$('sp1').style.display='inline';
				}else{
					$('sp1').style.display='none';
				}
				return flag;
			}
			
			function checkPassword(password1){
				var flag=false;
				var password=$('ctl00')['txtPassword'].value;
				if(password1.strip()!=password.strip()){
					$('sp2').style.display="inline";
				}else{
					$('sp2').style.display="none";
					flag=true;
				}
				return flag;
				
			}
		</script>
	</head>
	<body>
		<%@include file="../common/head1.jsp"%>
		<div class="login_step">
			注册步骤:
			<span class="red_bold">1.填写信息 </span><b>&gt;</b> 2.验证邮箱 <b>&gt;</b>3.注册成功
		</div>
		<div class="fill_message">
		
			<html:form method="post" action="registerOne.do" styleId="ctl00" onsubmit="return validateForm(this);">
				<h2>
					以下均为必填项
				</h2>
				<table class="tab_login">
					<tr>
						<td valign="top" class="w1">
							请填写您的Email地址：
						</td>
						<td>
							<html:text property="email" styleId="txtEmail"
								styleClass="text_input" onblur="checkEmailAjax(this.value);"/>
							<div class="text_left" id="emailValidMsg">
								<p>
									请填写有效的Email地址，在下一步中您将用此邮箱接收验证邮件。
								</p>
								<p style="color: red">
									<html:errors property="email"/>
									<span id="sp1" style="display:none">
										<bean:message key="error.email.exist"/>
									</span>
								</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="top" class="w1">
							设置您在当当网的昵称：
						</td>
						<td>
							<html:text property="nickname" styleId="txtNickName"
								styleClass="text_input" />
							<div class="text_left" id="nickNameValidMsg">
								<p>
									您的昵称可以由小写英文字母、中文、数字组成，
								</p>
								<p>
									长度4－20个字符，一个汉字为两个字符。
								</p>

								<p style="color: red">
									<html:errors property="nickname" />
								</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="top" class="w1">
							设置密码：
						</td>
						<td>
							<html:password property="password" styleId="txtPassword"
								styleClass="text_input" />
							<div class="text_left" id="passwordValidMsg">
								<p>
									您的密码可以由大小写英文字母、数字组成，长度6－20位。
								</p>
								<p style="color: red">
									<html:errors property="password" />
								</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="top" class="w1">
							再次输入您设置的密码：
						</td>
						<td>
							<html:password property="password1" styleId="txtRepeatPass"
								styleClass="text_input" onblur="checkPassword(this.value);"/>
							<div class="text_left" id="repeatPassValidMsg">
								<p style="color: red">
									<span id="sp2" style="display:none">
										<bean:message key="error.password.same"/>
									</span>
								</p>
							</div>
						</td>
					</tr>
					<tr>
						<td valign="top" class="w1">
							验证码：
						</td>
						<td>
							<img class="yzm_img" id='imgVcode' src="image.do"/>
							<input name="txtVerifyCode" type="text" id="txtVerifyCode"
								class="yzm_input" onblur="" />
							<div class="text_left t1">
								<p class="t1">
									<span id="vcodeValidMsg">请输入图片中的四个字母。</span><a href="javascript:;" 
										onclick="$(imgVcode).src='image.do?'+new Date().getTime()">看不清楚？换个图片</a>
								</p>
								<p style="color: red">
									<html:errors property="error.verify.number" />
								</p>
							</div>
						</td>
					</tr>
				</table>

				<div class="login_in">
					<html:submit styleId="btnClientRegister" styleClass="button_1">注 册</html:submit>
				</div>
			</html:form>
		</div>
		<%@include file="../common/foot1.jsp"%>
	</body>
</html>

